function info_gain =  estimate_info_gain(robo_map,angle,max_range,position)
check = zeros(size(robo_map));
global p_occ_sensor;
global p_empty_sensor ;

global log_odds_occ_sensor;
global log_odds_empty_sensor;
global log_odds_occ;

p_reachable = 1;
info_gain=0;
for i=1:0.5:max_range
    
    xy = uint64(position + i*[cos(angle),sin(angle)]);
    if(check(xy(1),xy(2))>0)
        continue;
    end
    check(xy(1),xy(2)) = 1;
    
    [p_occ p_empty] = logodds2prob(robo_map(xy(1),xy(2)));
    
    occ_log_odds = robo_map(xy(1),xy(2)) + log_odds_occ_sensor - log_odds_occ;
    free_log_odds = robo_map(xy(1),xy(2)) + log_odds_empty_sensor - log_odds_occ;
    
    [p_occ_sensor_ p_occ_sensor_not] = logodds2prob(occ_log_odds);
    [p_free_sensor_ p_free_sensor_not] = logodds2prob(free_log_odds);
    
    new_info = - p_reachable*(p_occ*(p_occ_sensor_*log(p_occ_sensor_) + p_occ_sensor_not*log(p_occ_sensor_not)) + p_empty*(p_free_sensor_*log(p_free_sensor_) + p_free_sensor_not*log(p_free_sensor_not)));
    old_info = - p_reachable*(p_occ*log(p_occ) + p_empty*log(p_empty));
    info_gain = info_gain + old_info - new_info;
    
    
    p_reachable = p_reachable*p_empty;
    
    if(p_reachable<0.0001)
        break;
    end
    
end